﻿using System;
using System.Collections.Generic;
using System.Text;
using EasyCommerce.DAL;

namespace EasyCommerce.BLL
{
    public class ShoppingCart
    {
        private List<CartItem> _cartItems;
        public List<CartItem> CartItems
        {
            get { return this._cartItems; }
            set { this._cartItems = value; }
        }

        private double _totalPrice;
        public double TotalPrice
        {
            get
            {
                _totalPrice = 0;
                foreach (CartItem cartItem in CartItems)
                {
                    _totalPrice += (cartItem.Item.ProductPrice * cartItem.Unit);
                }
                return _totalPrice;
            }
        }

        public void AddItemToCart(CartItem cartItem)
        {
            if (CartItems.Contains(cartItem))
            {
                
            }
        }

        public void RemoveItemFromCart(CartItem cartItem)
        {

        }

        public CartItem this[int index]
        {
            get { return this._cartItems[index]; }
            set { this._cartItems[index] = value; }
        }
    }
}
